export default function (meta, vm) {
  function initState() {
    vm.setState("is_page_demand", (args) => {
      return args.data?.type == 'file';
    });
  }
  return {
    onInit: function () {
      initState();

      vm.on("nodeClick", args => {
        if (args.model == "projs_proj_detail_demands") {
          vm.setData("projs_proj_detail_demands_obj", args.data);
        }
      });

      vm.on("createChildDemands", args => {
        let selData = vm.getData("projs_proj_detail_demands_obj");
        if (selData == null || selData.id == null) {
          vm.utils.message("请选择需求分析节点！");
          return false;
        }
        let parentId = selData.id;

        args.data.param = {
          "projectId": vm.getData()?.id,
          "parentId": parentId,
          "parentTitle": selData.title,
          "titles": ""
        };
        vm.utils.showDialog("dialog_batch_child_demands", args);
        return args.promise;
      });
    }
  }
}